import Vue from 'vue';
import Router from 'vue-router';

// import main from './main';
import home from './home';
import community from './comunity';
import cart from './cart';
import mine from './mine';
import goods from './goods';

Vue.use(Router);

let RouterModel = new Router({
  mode: 'history',  //去掉url中的#
  routes: [...home, ...community, ...cart, ...mine, ...goods],
});

// 路由跳转前，可以通过这个方法，进行权限控制
RouterModel.beforeEach((to, from, next) => {
  // const { Authorization, user_id} = Vue.prototype.$util.getLocalStorage('Authorization', 'user_id')
  // if(!Authorization && !user_id){
  //   if(to.meta.login){
  //     RouterModel.push({name: 'login', query: {redirect: to.name}});
  //     return;
  //   }
  // }
  next();
});


// 路由跳转后
RouterModel.afterEach((to, from) => {

});


export default RouterModel;
